package com.rongxun.common.aroute;

import android.content.Context;
import android.content.Intent;

import com.alibaba.android.arouter.launcher.ARouter;
import com.rongxun.api.UserInfoManager;

/**
 * 创建者     forza
 * 创建时间   2019/11/29 18:09
 * 描述
 */

public class RouteUtil {
    //Intent隐式启动 action
    public static final String LOGIN = "/login/LoginActivity";

    public static final String MAIN_A = "/main/MainActivity";
    public static final String MAIN_B = "/main/MainBctivity";


    /**
     * 首页AB面跳转
     */
    public static void forwardHome(Context context) {
        String path = MAIN_A;

        if (UserInfoManager.NEED_TRANSACTION.equals(UserInfoManager.getInstance(context).getUIConfig())) {
            path = MAIN_B;
        }

        ARouter.getInstance().build(path)
                .addFlags(Intent.FLAG_ACTIVITY_CLEAR_TASK)
                .navigation();
    }

    /**
     * 登录过期 跳转登录页
     */
    public static void forwardLogin() {

        forwardNormal(LOGIN);

        ARouter.getInstance().build(LOGIN)
                .navigation();
    }

    /**
     * 登录过期 跳转登录页
     */
    public static void forwardNormal(String path) {
        ARouter.getInstance().build(path)
                .addFlags(Intent.FLAG_ACTIVITY_CLEAR_TASK)
                .navigation();
    }


}
